* drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot().
*/
grub_uint8_t
-grub_efi_get_secureboot (void)
+grub_efi_get_secureboot_real (bool check_moksb)
{
static grub_guid_t efi_variable_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
grub_efi_status_t status;
goto out;
}
+ grub_dprintf ("efi",
+ "MokSBState check enabled in GRUB: %s\n",
+ (check_moksb == true) ? "yes" : "no");
+
+ if (check_moksb == false)
+ {
+ secureboot = GRUB_EFI_SECUREBOOT_MODE_ENABLED;
+ goto out;
+ }
+
/*
* See if a user has put the shim into insecure mode. If so, and if the
* variable doesn't have the runtime attribute set, we might as well
.write = shim_lock_verifier_write
};
+void
+grub_shim_lock_protocol_setup (void)
+{
+ /*
+ * Skip only if UEFI Secure Boot is really disabled in firmware, no shim lock
+ * is being detected so this ensures that UEFI LoadImage() is used.
+ */
+ if (grub_efi_get_secureboot_real (false) != GRUB_EFI_SECUREBOOT_MODE_ENABLED)
+ return;
+
+ /*
+ * Set up shim protocol if UEFI Secure Boot is enabled or shim is in insecure
+ * mode. Either the legacy fallback loader or the shim loader, which overrides
+ * UEFI LoadImage(), will be used.
+ */
+ /* Find both shim protocols. */
+ shim_loader = grub_efi_locate_protocol (&shim_loader_guid, 0);
+ shim_lock = grub_efi_locate_protocol (&shim_lock_guid, 0);
+ /* Register shim loader if supported. */
+ if (shim_loader != NULL)
+ grub_efi_register_loader (shim_loader);
+}
+
void
grub_shim_lock_verifier_setup (void)
{
if (grub_efi_get_secureboot () != GRUB_EFI_SECUREBOOT_MODE_ENABLED)
return;
- /* Find both shim protocols. */
- shim_loader = grub_efi_locate_protocol (&shim_loader_guid, 0);
- shim_lock = grub_efi_locate_protocol (&shim_lock_guid, 0);
-
/* shim is missing, check if GRUB image is built with --disable-shim-lock. */
if (shim_loader == NULL && shim_lock == NULL)
{
/* Enforce shim_lock_verifier. */
grub_verifier_register (&shim_lock_verifier);
- /* Register shim loader if supported. */
- grub_efi_register_loader (shim_loader);
-
grub_env_set ("shim_lock", "y");
grub_env_export ("shim_lock");
}
#ifdef GRUB_MACHINE_EFI
extern grub_uint8_t
-EXPORT_FUNC (grub_efi_get_secureboot) (void);
+EXPORT_FUNC (grub_efi_get_secureboot_real) (bool check_moksb);
+
+static inline grub_uint8_t
+grub_efi_get_secureboot (void)
+{
+ return grub_efi_get_secureboot_real (true);
+}
extern bool
EXPORT_FUNC (grub_is_using_legacy_shim_lock_protocol) (void);
extern void
grub_shim_lock_verifier_setup (void);
+
+extern void
+grub_shim_lock_protocol_setup (void);
+
#else
static inline grub_uint8_t
grub_efi_get_secureboot (void)